# Monarc makefile

CC  = gcc
AS  = nasm
LD  = ld
AR  = ar
SED = sed
PL = perl

ifndef BASE
	BASE = ./
endif

INCL = \
	-I$(BASE)/include
	

DEFINES = \

C_OPT = -Wall -O3 -mno-stack-arg-probe -ffreestanding -nostartfiles -nodefaultlibs -nostdlib -nostdinc $(INCL) $(DEFINES)
OC_OPT = -Wall -O3 -mno-stack-arg-probe -ffreestanding -nostartfiles -nodefaultlibs -nostdlib -nostdinc $(INCL) $(DEFINES)

CC_OPT = -Wall -O3 -mno-stack-arg-probe -nostartfiles -fno-builtin -nodefaultlibs -nostdlib -nostdinc $(INCL) $(DEFINES)
OCC_OPT = -Wall -O3 -mno-stack-arg-probe -nostartfiles -fno-builtin -nodefaultlibs -nostdlib -nostdinc $(INCL) $(DEFINES)

MKDIR = mkdir
CP = cp
CAT = cat
RM = rm -f

c_sources = \
	console.c \
	printf.c \
	string/strbase.c \
	string/string.c \
	string/strncat.c \
	string/strrchr.c \
	string/strstr.c \
	stdlib/random.c \
	stdlib/stdlib.c \
	stdlib/strtoi.c \
	stdlib/strtol.c \
	stdlib/strtou.c \
	stdlib/strtoul.c \
	ioformat/sprintf.c \
	ioformat/sscanf.c \
	ioformat/ucvt.c \
	
	

sources = \


asm_sources = \
	
	

all: libklibc.a

clean:
	$(RM) *.o libklibc.a string/*.o stdlib/*.o ioformat/*.o

libklibc.a: $(sources:.cc=.o) $(c_sources:.c=.o) $(asm_sources:.asm=.o)
	ar cru $@ $?

%.o : %.asm
	$(REDIR) $(AS) -fwin32 $< -o $@

%.o: %.c
	$(REDIR) $(CC) $(OC_OPT) -c $< -o $@

%.o: %.cc
	$(REDIR) $(CC) $(OCC_OPT) -c $< -o $@

